import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _startsWith from "lodash/startsWith";

var _class;

/*eslint-disable*/
import React from 'react';
import { Switch, withRouter } from 'dva/router';

var WrapperSwitch = withRouter(_class = /*#__PURE__*/function (_Switch) {
  _inherits(WrapperSwitch, _Switch);

  var _super = _createSuper(WrapperSwitch);

  function WrapperSwitch() {
    _classCallCheck(this, WrapperSwitch);

    return _super.apply(this, arguments);
  }

  _createClass(WrapperSwitch, [{
    key: "shouldComponentUpdate",
    value: function shouldComponentUpdate(nextProps, _, nextLegacyContext) {
      var _nextLegacyContext$ro = nextLegacyContext.router;
      _nextLegacyContext$ro = _nextLegacyContext$ro === void 0 ? {} : _nextLegacyContext$ro;
      var _nextLegacyContext$ro2 = _nextLegacyContext$ro.route;
      _nextLegacyContext$ro2 = _nextLegacyContext$ro2 === void 0 ? {} : _nextLegacyContext$ro2;
      var _nextLegacyContext$ro3 = _nextLegacyContext$ro2.location;
      _nextLegacyContext$ro3 = _nextLegacyContext$ro3 === void 0 ? {} : _nextLegacyContext$ro3;
      var pathname = _nextLegacyContext$ro3.pathname;
      var activeTabKey = nextProps.activeTabKey,
          tabKey = nextProps.tabKey,
          tabPathname = nextProps.tabPathname;
      /* todo 只有当 pathname 等于 Tab 里的 path 时 才能更新 */

      return tabKey === activeTabKey &&
      /* sometimes the pathname is different with tabPathname */
      _startsWith(decodeURIComponent(pathname), decodeURIComponent(tabPathname));
    }
  }]);

  return WrapperSwitch;
}(Switch)) || _class;

export { WrapperSwitch as default };